package com.gsj.system.controller;


import com.gsj.common.pojo.R;
import com.gsj.system.config.OperLog;
import com.gsj.system.pojo.UserVo;
import com.gsj.system.pojo.UserVoSecond;
import com.gsj.system.pojo.UserVoThird;
import com.gsj.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clmseighth
 * @description:
 * @author: 张巍蓝
 * @create: 2021-07-23 15:10
 **/

@RestController
@RequestMapping("system/menu")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("queryallUser/{currentPage}/{pageSize}")
    @OperLog( title= "查询所有User",operatorType ="0",business_type = "0")
    public R queryallUser(@PathVariable("currentPage")Integer currentPage,
                          @PathVariable("pageSize")Integer pageSize,
                          @RequestBody UserVo uservo){
        return userService.queryAllUser(currentPage,pageSize,uservo);
    }
    @PutMapping("addUser/{username}")
    @OperLog( title= "新增用户表",operatorType ="0",business_type = "0")
    public R addUser(@RequestBody UserVoThird userVo,@PathVariable("username")String username){
        return userService.addUser(userVo,username);
    }
    @PutMapping("editUser/{username}")
    @OperLog( title= "修改用户表",operatorType ="0",business_type = "0")
    public R editUser(@RequestBody UserVo userVo,@PathVariable("username")String username){
        return userService.editUser(userVo,username);
    }
    @GetMapping("querybyUserid")
    @OperLog( title= "通过userid查询",operatorType ="0",business_type = "0")
    public R querybyUserid(Integer userId){
        return userService.querybyUserid(userId);
    }
    @DeleteMapping("deleteUserBYid")
    @OperLog( title= "通过userid删除",operatorType ="0",business_type = "0")
    public R deleteUserBYid(Integer userId){
        return userService.deleteUserBYid(userId);
    }
    @PutMapping("editUserStatus")
    @OperLog( title= "通过userid更改状态",operatorType ="0",business_type = "0")
    public R editUserStatus(Integer id,Integer status){
        return userService.editUserStatus(id,status);
    }
    @PutMapping("editPassword")
    @OperLog( title= "修改用户表中密码",operatorType ="0",business_type = "0")
    public R editPassword(@RequestBody UserVoSecond userVoSecond){
        return userService.editPassword(userVoSecond);
    }


}
